using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;

namespace CodeStory.Core.UI
{
	public class PortletContainer : UserControl
	{
		public PortletContainer() {
			AppRelativeTemplateSourceDirectory = TempAppRelativeTemplateSourceDirectory;
		}

		public string TempAppRelativeTemplateSourceDirectory {
			get {
				object p = Context.Items[PageHierarchyBuilder.AppRelativeTemplateSourceDirectoryDataKey];
				if (p == null) {
					p = AppRelativeTemplateSourceDirectory;
				}
				return p.ToString();
			}
		}
		public string PortletTitle {
			set {
				ITextControl c = FindControl("Title") as ITextControl;
				if (c != null) {
					c.Text = value;
				}
			}
		}
		public bool TitleBarVisible {
			get {
				if (TitleBarControl == null) return false;
				return TitleBarControl.Visible;
			}
			set {
				if (TitleBarControl == null) return;
				TitleBarControl.Visible = value;
			}
		}
		Control titlebarcontrol;
		private Control TitleBarControl {
			get {
				if (titlebarcontrol == null) {
					titlebarcontrol = FindControl("TitleBar");
				}
				return titlebarcontrol;
			}
		}
	}
}
